﻿<navigation:Page
    xmlns:my1="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Input.Toolkit"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    mc:Ignorable="d"
    xmlns:navigation="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Navigation"
    xmlns:riaControls="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Ria"
    xmlns:my="clr-namespace:AdminApp.Web.Services"
    xmlns:data="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Data"
    xmlns:controls="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls"
    xmlns:my2="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Toolkit"
    xmlns:dataInput="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Data.Input"
    xmlns:System_Windows_Data="clr-namespace:System.Windows.Data;assembly=System.Windows.Controls.Ria"
    xmlns:converter="clr-namespace:AdminApp"
    xmlns:my3="clr-namespace:TheOliver.DigitalSignage.Common;assembly=TheOliver.DigitalSignage.Common"
    xmlns:src="clr-namespace:AdminApp" xmlns:AdminApp_Controls="clr-namespace:AdminApp.Controls"
    x:Class="AdminApp.Views.Slots"
    d:DesignWidth="640"
    d:DesignHeight="480"
    Title="Slots Page"
    >
    <navigation:Page.Resources>
        <src:SessionConverter
            x:Name="SessionConverter1" />
        <src:SpeakerConverter
            x:Name="SpeakerConverter1" />
        <src:RoomConverter
            x:Name="RoomConverter1" />
        <src:SpeakerIdImageConverter
            x:Name="SpeakerImageConverter1" />
        <my3:TimeConverter
            x:Key="_timeConverter" />
        <my3:DateConverter
            x:Key="_dateConverter" />
    </navigation:Page.Resources>
    <my2:BusyIndicator
        IsBusy="{Binding DomainContext.IsLoading, ElementName=eventDomainDataSource}"
        BusyContent="Loading Event Data ...">
        <my2:BusyIndicator
            IsBusy="{Binding DomainContext.IsLoading, ElementName=roomDomainDataSource}"
            BusyContent="Loading Room Data ...">
            <my2:BusyIndicator
                IsBusy="{Binding DomainContext.IsLoading, ElementName=sessionDomainDataSource}"
                BusyContent="Loading Session Data ...">
                <my2:BusyIndicator
                    IsBusy="{Binding DomainContext.IsLoading, ElementName=speakerDomainDataSource}"
                    BusyContent="Loading Speaker Data ...">
                    <my2:BusyIndicator
                        IsBusy="{Binding DomainContext.IsLoading, ElementName=slotDomainDataSource}"
                        BusyContent="Loading Slot Data ...">

                        <Grid
                            x:Name="LayoutRoot"
                            Margin="0">
                            <Grid.RowDefinitions>
                                <RowDefinition
                                    Height="28" />
                                <RowDefinition />
                                <RowDefinition
                                    Height="51" />
                            </Grid.RowDefinitions>
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition
                                    Width="0.483*" />
                                <ColumnDefinition
                                    Width="0.517*" />
                            </Grid.ColumnDefinitions>
                            <StackPanel
                                x:Name="_filterpanel"
                                Margin="8,4,0,4"
                                Orientation="Horizontal"
                                VerticalAlignment="Center"
                                Grid.ColumnSpan="2">
                                <TextBlock
                                    x:Name="_eventLabel"
                                    TextWrapping="Wrap"
                                    Text="Event"
                                    VerticalAlignment="Center"
                                    Margin="0,0,4,0" />
                                <ComboBox
                                    x:Name="_eventCombo"
                                    HorizontalAlignment="Left"
                                    Width="115"
                                    ItemsSource="{Binding Data, ElementName=eventDomainDataSource}"
                                    DisplayMemberPath="Name"
                                    SelectionChanged="_eventCombo_SelectionChanged" />
                                <Button
                                    x:Name="_clearEvent"
                                    Content="X"
                                    Margin="2,0,4,0" />
                                <TextBlock
                                    x:Name="_roomLabel"
                                    TextWrapping="Wrap"
                                    Text="Room"
                                    VerticalAlignment="Center"
                                    Margin="8,0,4,0" />
                                <ComboBox
                                    x:Name="_selectRoomCombo"
                                    Width="120"
                                    DisplayMemberPath="Name"
                                    ItemsSource="{Binding DomainContext.Rooms, ElementName=roomDomainDataSource}"
                                    SelectionChanged="_roomCombo_SelectionChanged" />
                                <Button
                                    x:Name="_clearRoom"
                                    Content="X"
                                    Margin="2,0,4,0" />
                                <TextBlock
                                    x:Name="_dayLabel"
                                    TextWrapping="Wrap"
                                    Text="Day"
                                    VerticalAlignment="Center"
                                    Margin="8,0,4,0" />
                                <ComboBox
                                    x:Name="_dayCombo"
                                    Width="120"
                                    ItemsSource="{Binding Data, ElementName=allDatesByRoomDomainDataSource}"
                                    SelectionChanged="_dayCombo_SelectionChanged"
                                    DisplayMemberPath="Date" />
                                <Button
                                    x:Name="_clearDay"
                                    Content="X"
                                    Margin="2,0,4,0" />
                            </StackPanel>
                            <StackPanel
                                Margin="8,0,151,8"
                                x:Name="_addRemovePanel"
                                VerticalAlignment="Bottom"
                                Orientation="Horizontal"
                                Grid.Row="2"
                                d:LayoutOverrides="Width">
                                <Button
                                    Content="Add"
                                    Height="23"
                                    x:Name="_add"
                                    Width="75"
                                    Click="_add_Click" />
                                <Button
                                    Content="Remove"
                                    Height="23"
                                    x:Name="_remove"
                                    Width="75"
                                    Click="_remove_Click" />
                            </StackPanel>
                            <StackPanel
                                HorizontalAlignment="Right"
                                x:Name="_changesPanel"
                                Orientation="Horizontal"
                                Margin="0,0,8,8"
                                Grid.Row="2"
                                VerticalAlignment="Bottom"
                                Grid.Column="1"/>
                            <riaControls:DomainDataSource
                                AutoLoad="True"
                                Height="0"
                                LoadedData="sessionDomainDataSource_LoadedData"
                                x:Name="sessionDomainDataSource"
                                QueryName="GetSessionQuery"
                                Width="0"
                                Margin="171,12,160,23"
                                Grid.Row="2"
                                Grid.Column="1">
                                <riaControls:DomainDataSource.DomainContext>
                                    <my:DigitalSignageDomainContext />
                                </riaControls:DomainDataSource.DomainContext>
                            </riaControls:DomainDataSource>
                            <riaControls:DomainDataSource
                                AutoLoad="True"
                                Height="0"
                                LoadedData="speakerDomainDataSource_LoadedData"
                                x:Name="speakerDomainDataSource"
                                QueryName="GetSpeakerQuery"
                                Width="0"
                                Margin="171,12,160,23"
                                Grid.Row="2"
                                Grid.Column="1">
                                <riaControls:DomainDataSource.DomainContext>
                                    <my:DigitalSignageDomainContext />
                                </riaControls:DomainDataSource.DomainContext>
                            </riaControls:DomainDataSource>
                            <riaControls:DomainDataSource
                                AutoLoad="True"
                                Height="0"
                                LoadedData="eventDomainDataSource_LoadedData"
                                x:Name="eventDomainDataSource"
                                QueryName="GetEventQuery"
                                Width="0"
                                Margin="160,14,149,14">
                                <riaControls:DomainDataSource.DomainContext>
                                    <my:DigitalSignageDomainContext />
                                </riaControls:DomainDataSource.DomainContext>
                            </riaControls:DomainDataSource>
                            <riaControls:DomainDataSource
                                AutoLoad="False"
                                Height="0"
                                LoadedData="roomDomainDataSource_LoadedData"
                                x:Name="roomDomainDataSource"
                                QueryName="GetRoomByEvent"
                                Width="0"
                                Margin="171,12,160,23"
                                Grid.Row="2"
                                Grid.Column="1">
                                <riaControls:DomainDataSource.DomainContext>
                                    <my:DigitalSignageDomainContext />
                                </riaControls:DomainDataSource.DomainContext>
                                <riaControls:DomainDataSource.QueryParameters>
                                    <riaControls:ControlParameter
                                        ControlName="_eventCombo"
                                        ParameterName="eventId"
                                        PropertyName="SelectedItem.Id"
                                        RefreshEventName="SelectionChanged" />
                                </riaControls:DomainDataSource.QueryParameters>
                            </riaControls:DomainDataSource>
                            <riaControls:DomainDataSource
                                AutoLoad="False"
                                Height="0"
                                LoadedData="allDatesByRoomDomainDataSource_LoadedData"
                                x:Name="allDatesByRoomDomainDataSource"
                                QueryName="GetDateByRoomIdQuery"
                                Width="0"
                                Grid.Column="1"
                                Margin="11,14,320,14">
                                <riaControls:DomainDataSource.DomainContext>
                                    <my:DigitalSignageDomainContext />
                                </riaControls:DomainDataSource.DomainContext>
                                <riaControls:DomainDataSource.QueryParameters>
                                    <riaControls:ControlParameter
                                        ControlName="_roomCombo"
                                        ParameterName="roomId"
                                        PropertyName="SelectedItem.RoomId"
                                        RefreshEventName="SelectionChanged" />
                                </riaControls:DomainDataSource.QueryParameters>
                            </riaControls:DomainDataSource>
                            <riaControls:DomainDataSource
                                AutoLoad="False"
                                Height="0"
                                LoadedData="slotDomainDataSource_LoadedData"
                                SubmittedChanges="slotDomainDataSource_SubmittedChanges"
                                x:Name="slotDomainDataSource"
                                QueryName="GetSlotsByRoomAndDate"
                                Width="0"
                                Margin="171,12,160,23"
                                Grid.Row="2"
                                Grid.Column="1">

                                <riaControls:DomainDataSource.DomainContext>
                                    <my:DigitalSignageDomainContext />
                                </riaControls:DomainDataSource.DomainContext>

                            </riaControls:DomainDataSource>
                            <ListBox
                                x:Name="_slotList"
                                Margin="11,12,8,8"
                                Grid.Row="1"
                                ItemsSource="{Binding DomainContext.Slots, ElementName=slotDomainDataSource, Mode=TwoWay}"
                                SelectionChanged="_slotList_SelectionChanged">
                                <ListBox.ItemTemplate>
                                    <DataTemplate>
                                        <Grid
                                            DataContext="{Binding}" Width="316">
                                        	<Grid.ColumnDefinitions>
                                        		<ColumnDefinition/>
                                        		<ColumnDefinition Width="76"/>
                                        	</Grid.ColumnDefinitions>
                                            <Rectangle
                                                Margin="2"
                                                Stroke="Black" Grid.ColumnSpan="2">
                                                <Rectangle.Fill>
                                                    <LinearGradientBrush
                                                        EndPoint="0.5,0"
                                                        StartPoint="0.5,1">
                                                        <GradientStop
                                                            Color="Black"
                                                            Offset="0.858" />
                                                        <GradientStop
                                                            Color="White"
                                                            Offset="1" />
                                                    </LinearGradientBrush>
                                                </Rectangle.Fill>
                                            </Rectangle>
                                            <StackPanel
                                                x:Name="LayoutRoot"
                                                Margin="4,12,4,4" Grid.ColumnSpan="1">

                                                <StackPanel
                                                    x:Name="_dateTimeGroup"
                                                    HorizontalAlignment="Left"
                                                    Orientation="Horizontal">

                                                    <TextBlock
                                                        x:Name="_time"
                                                        Text="{Binding Time, ConverterParameter=HH:mm, Converter={StaticResource _timeConverter}}"
                                                        Foreground="White"
                                                        HorizontalAlignment="Left"
                                                        Height="16"
                                                        FontSize="10.667"
                                                        FontWeight="Bold" />

                                                    <TextBlock
                                                        x:Name="_date"
                                                        Text="{Binding Date, ConverterParameter=dd.MM.yyyy, Converter={StaticResource _dateConverter}}"
                                                        Foreground="White"
                                                        HorizontalAlignment="Left"
                                                        Margin="4,0,0,0"
                                                        Height="16"
                                                        FontSize="10.667"
                                                        FontWeight="Bold" />

                                                </StackPanel>
                                                <TextBlock
                                                    x:Name="_sessionShortTitle"
                                                    Text="{Binding SessionId, Converter={StaticResource SessionConverter1}}"
                                                    Foreground="White"
                                                    HorizontalAlignment="Left"
                                                    Height="16"
                                                    FontSize="10.667"
                                                    FontWeight="Bold" />
                                                <StackPanel
                                                    x:Name="_sessionLengthGroup"
                                                    Height="16"
                                                    Orientation="Horizontal"
                                                    d:LayoutOverrides="Width">

                                                    <TextBlock
                                                        x:Name="_sessionLengthLabel"
                                                        TextWrapping="Wrap"
                                                        Text="Length"
                                                        Width="315"
                                                        Height="16"
                                                        FontSize="10.667"
                                                        Foreground="White" />

                                                    <TextBlock
                                                        x:Name="_sessionLength"
                                                        Text="{Binding SessionLength}"
                                                        Foreground="White"
                                                        VerticalAlignment="Bottom"
                                                        Height="16"
                                                        FontSize="10.667" />
                                                </StackPanel>

                                                <TextBlock
                                                    x:Name="_speakerFirstname"
                                                    Text="{Binding SpeakerId, Converter={StaticResource SpeakerConverter1}}"
                                                    Foreground="White"
                                                    HorizontalAlignment="Left"
                                                    Height="16"
                                                    FontSize="10.667" />

                                                <TextBlock
                                                    x:Name="_roomName"
                                                    Text="{Binding RoomId, Converter={StaticResource RoomConverter1}}"
                                                    HorizontalAlignment="Left"
                                                    Height="16"
                                                    FontSize="10.667"
                                                    Foreground="White" />

                                            </StackPanel>
                                            <Image x:Name="_speakerImage" Grid.Column="1" Margin="4"
                                                   Source="{Binding SpeakerId, Converter={StaticResource SpeakerImageConverter1}}"/>
                                        </Grid>
                                        <!--
                                        <Grid
                                            Height="100"
                                            Width="250">
                                            <StackPanel
                                                Orientation="Horizontal"
                                                VerticalAlignment="Top"
                                                Height="19">
                                                <TextBlock
                                                    x:Name="_time"
                                                    Text="{Binding Time, ConverterParameter=HH:mm, Converter={StaticResource _timeConverter} }"
                                                    Margin="0"
                                                    HorizontalAlignment="Left"
                                                    VerticalAlignment="Center" />
                                                <TextBlock
                                                    x:Name="_date"
                                                    Text="{Binding Date, ConverterParameter=dd.MM.yyyy, Converter={StaticResource _dateConverter}}"
                                                    Margin="0"
                                                    HorizontalAlignment="Left"
                                                    VerticalAlignment="Center" />
                                            </StackPanel>
                                            <StackPanel
                                                HorizontalAlignment="Left"
                                                Margin="0,23,0,0"
                                                Orientation="Vertical"
                                                VerticalAlignment="Top"
                                                MinWidth="100"
                                                MinHeight="20">
                                                <TextBlock
                                                    x:Name="_length"
                                                    Text="{Binding Length}"
                                                    HorizontalAlignment="Left" />
                                                <TextBlock
                                                    x:Name="_sessionName"
                                                    Text="{Binding SessionId, Converter={StaticResource SessionConverter1}}"
                                                    HorizontalAlignment="Left" />
                                                <TextBlock
                                                    x:Name="_speakerLastName"
                                                    Text="{Binding SpeakerId, Converter={StaticResource SpeakerConverter1}}"
                                                    HorizontalAlignment="Left" />
                                                <TextBlock
                                                    x:Name="_speaker2LastName"
                                                    Text="{Binding Speaker2Id, Converter={StaticResource SpeakerConverter1}}"
                                                    HorizontalAlignment="Left" />
                                                <TextBlock
                                                    x:Name="_room"
                                                    Text="{Binding RoomId, Converter={StaticResource RoomConverter1}}"
                                                    HorizontalAlignment="Left" />
                                                <TextBlock
                                                    x:Name="_shortTitle"
                                                    Text="{Binding SessionId, Converter={StaticResource SessionConverter1}}"
                                                    HorizontalAlignment="Left" />
                                            </StackPanel>
                                        </Grid>-->
                                    </DataTemplate>
                                </ListBox.ItemTemplate>
                            </ListBox>

                            <Grid
                                DataContext="{Binding SelectedItem, ElementName=_slotList, Mode=TwoWay}"
                                Grid.Row="1"
                                Margin="8"
                                x:Name="_detailsGrid"
                                VerticalAlignment="Top"
                                Grid.Column="1">
                                <Grid.ColumnDefinitions>
                                    <ColumnDefinition
                                        Width="0.244*" />
                                    <ColumnDefinition
                                        Width="0.756*" />
                                </Grid.ColumnDefinitions>
                                <Grid.RowDefinitions>
                                    <RowDefinition
                                        Height="0.125*" />
                                    <RowDefinition
                                        Height="0.125*" />
                                    <RowDefinition
                                        Height="0.125*" />
                                    <RowDefinition
                                        Height="0.125*" />
                                    <RowDefinition
                                        Height="0.125*" />
                                    <RowDefinition
                                        Height="0.125*" />
                                    <RowDefinition
                                        Height="0.125*" />
                                    <RowDefinition
                                        Height="0.125*" />
                                </Grid.RowDefinitions>
                                <dataInput:Label
                                    x:Name="_dateLabel"
                                    Content="Date:"
                                    Grid.Column="0"
                                    Grid.Row="0"
                                    HorizontalAlignment="Left"
                                    Margin="3"
                                    VerticalAlignment="Center" />
                                <controls:DatePicker
                                    Grid.Column="1"
                                    Grid.Row="0"
                                    Margin="4,4,8,4"
                                    x:Name="_date"
                                    SelectedDate="{Binding Date, Mode=TwoWay, NotifyOnValidationError=true, ValidatesOnExceptions=true}" />
                                <dataInput:Label
                                    x:Name="_timeLabel"
                                    Content="Time:"
                                    Grid.Column="0"
                                    Grid.Row="1"
                                    HorizontalAlignment="Left"
                                    Margin="3,7,0,6"
                                    d:LayoutOverrides="Height" />
                                <my1:TimeUpDown
                                    x:Name="_time"
                                    Grid.Column="1"
                                    Margin="4,5,0,5"
                                    Grid.Row="1"
                                    HorizontalAlignment="Left"
                                    Value="{Binding Time, Mode=TwoWay, NotifyOnValidationError=true, ValidatesOnExceptions=true}"
                                    Width="66" />
                                <TextBox
                                    Grid.Column="1"
                                    Grid.Row="1"
                                    Margin="0,4,8,4"
                                    x:Name="_timeTextBox"
                                    Text="{Binding Time, Mode=TwoWay, NotifyOnValidationError=true, ValidatesOnExceptions=true}"
                                    HorizontalAlignment="Right"
                                    Width="98" />
                                <dataInput:Label
                                    x:Name="_lengthLabel"
                                    Content="Length:"
                                    Grid.Column="0"
                                    Grid.Row="2"
                                    HorizontalAlignment="Left"
                                    Margin="3"
                                    VerticalAlignment="Center" />
                                <my1:NumericUpDown
                                    x:Name="_length"
                                    Grid.Column="1"
                                    HorizontalAlignment="Left"
                                    Margin="4,4,0,4"
                                    Grid.Row="2"
                                    Value="{Binding Length, Mode=TwoWay, NotifyOnValidationError=true, ValidatesOnExceptions=true}"
                                    Width="43" />
                                <TextBox
                                    Grid.Column="1"
                                    Grid.Row="2"
                                    Margin="0,4,8,4"
                                    x:Name="_lengthTextBox"
                                    Text="{Binding Length, Mode=TwoWay, NotifyOnValidationError=true, ValidatesOnExceptions=true}"
                                    HorizontalAlignment="Right"
                                    Width="98" />
                                <dataInput:Label
                                    x:Name="_roomLabel1"
                                    Content="Room:"
                                    Grid.Column="0"
                                    Grid.Row="3"
                                    HorizontalAlignment="Left"
                                    Margin="3"
                                    VerticalAlignment="Center" />

                                <ComboBox
                                    x:Name="_roomIdCombo"
                                    Grid.Column="1"
                                    Grid.Row="3"
                                    Margin="4,4,37,4"
                                    ItemsSource="{Binding Data, ElementName=roomDomainDataSource1}"
                                    SelectionChanged="_roomIdCombo_SelectionChanged"
                                    DisplayMemberPath="Name" />
                                <Button
                                    x:Name="_clearRoom1"
                                    Content="X"
                                    Margin="4"
                                    d:LayoutOverrides="Height"
                                    Grid.Column="1"
                                    HorizontalAlignment="Right"
                                    Grid.Row="3"
                                    Width="25"
                                    Click="_clearRoom1_Click" />

                                <dataInput:Label
                                    x:Name="_sessionLabel"
                                    Content="Session:"
                                    Grid.Column="0"
                                    Grid.Row="4"
                                    HorizontalAlignment="Left"
                                    Margin="3"
                                    VerticalAlignment="Center" />

                                <ComboBox
                                    x:Name="_sessionIdCombo"
                                    Grid.Column="1"
                                    Grid.Row="4"
                                    Margin="4,4,37,4"
                                    ItemsSource="{Binding Data, ElementName=sessionDomainDataSource}"
                                    SelectionChanged="_sessionIdCombo_SelectionChanged"
                                    DisplayMemberPath="ShortTitle" />
                                <Button
                                    x:Name="_clearSession"
                                    Content="X"
                                    Grid.Column="1"
                                    HorizontalAlignment="Right"
                                    Margin="4"
                                    Grid.Row="4"
                                    Width="25"
                                    d:LayoutOverrides="Height"
                                    Click="_clearSession_Click" />

                                <dataInput:Label
                                    x:Name="_speakerLabel"
                                    Content="Speaker:"
                                    Grid.Column="0"
                                    Grid.Row="5"
                                    HorizontalAlignment="Left"
                                    Margin="3,5,0,8"
                                    d:LayoutOverrides="Height" />
                                <ComboBox
                                    x:Name="_speakerIdCombo"
                                    SelectionChanged="_speakerIdCombo_SelectionChanged"
                                    Grid.Column="1"
                                    Grid.Row="5"
                                    Margin="4,4,37,4"
                                    ItemsSource="{Binding Data, ElementName=speakerDomainDataSource}"
                                    DisplayMemberPath="Lastname" />
                                <Button
                                    x:Name="_clearSpeaker1"
                                    Content="X"
                                    Grid.Column="1"
                                    HorizontalAlignment="Right"
                                    Margin="4"
                                    Grid.Row="5"
                                    Width="25"
                                    d:LayoutOverrides="Height"
                                    Click="_clearSpeaker1_Click" />
                            </Grid>
                            <riaControls:DomainDataSource
                                AutoLoad="True"
                                Height="0"
                                LoadedData="roomDomainDataSource1_LoadedData"
                                x:Name="roomDomainDataSource1"
                                QueryName="GetRoomQuery"
                                Width="0"
                                Grid.Column="1"
                                Margin="11,14,320,14">
                                <riaControls:DomainDataSource.DomainContext>
                                    <my:DigitalSignageDomainContext />
                                </riaControls:DomainDataSource.DomainContext>
                            </riaControls:DomainDataSource>

                        	<AdminApp_Controls:SaveAndRejectControl
                        		Grid.Column="1"
                        		Margin="0"
                        		Grid.Row="2"
                        		DataContext="{Binding ElementName=slotDomainDataSource}" HorizontalAlignment="Right" d:LayoutOverrides="Height" VerticalAlignment="Bottom" />

                        </Grid>
                    </my2:BusyIndicator>
                </my2:BusyIndicator>
            </my2:BusyIndicator>
        </my2:BusyIndicator>
    </my2:BusyIndicator>
</navigation:Page>
